package com.zjj.concurrent.disruptor.consumer;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;
import com.zjj.concurrent.disruptor.event.OrderEvent;

/**
 * @author zhanglei.zjj
 * @description 消费者
 * @date 2023/6/4 18:16
 */
public class OrderEventHandler implements EventHandler<OrderEvent>, WorkHandler {
    @Override
    public void onEvent(OrderEvent event, long sequence, boolean endOfBatch) throws Exception {
        // TODO 消费逻辑
        System.out.println("消费者获取数据value:"+ event.getValue()+",name:"+event.getName());
    }

    @Override
    public void onEvent(Object event) throws Exception {
        // TODO 消费逻辑
        OrderEvent orderEvent = (OrderEvent) event;
        System.out.println("消费者"+ Thread.currentThread().getName()
                +"获取数据value:"+ orderEvent.getValue()+",name:"+orderEvent.getName());
    }
}
